﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using T2.WebSecurity.Business.Entities.Interfaces;

namespace T2.WebSecurity.ASPMVC.ViewModel
{
    public class BaseViewModel
    {
        //protected string ROLE_ADMIN = "sysdmin";

        private MembershipUser m_user;

        public MembershipUser User
        {
            get
            {
                if (m_user == null)
                {
                    m_user = Membership.GetUser();
                }
                return m_user;
            }
        }

        public bool IsUserInRole(string roleName)
        {
            return Roles.IsUserInRole(this.User.UserName, roleName);
        }


        //#region filter by user method overloads

        //protected List<IApplication_biz> FilterListByLoginUser(List<IApplication_biz> retValBiz)
        //{
        //    retValBiz = retValBiz.Where(c => c.ApplicationUser_List.Count > 0 && c.ApplicationUser_List.FirstOrDefault().UserId == (int)User.ProviderUserKey).ToList();
        //    return retValBiz;
        //}

        //protected List<IUserProfile_biz> FilterListByLoginUser(List<IUserProfile_biz> retValBiz)
        //{
        //    retValBiz = retValBiz.Where(c => c.UserId == (int)User.ProviderUserKey).ToList();
        //    return retValBiz;
        //}

        //protected List<IUsersInRoles_biz> FilterListByLoginUser(List<IUsersInRoles_biz> retValBiz)
        //{
        //    retValBiz = retValBiz.Where(c => c.UserId == (int)User.ProviderUserKey).ToList();
        //    return retValBiz;
        //}

        //protected List<IApplicationRoles_biz> FilterListByLoginUser(List<IApplicationRoles_biz> retValBiz)
        //{
        //    retValBiz = retValBiz.Where(c => c.UsersInRoles_List.FirstOrDefault().UserId == (int)User.ProviderUserKey).ToList();
        //    return retValBiz;
        //}

        //#endregion
    }
}